package ToDoList;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

@Entity
@Getter
@Setter
public class Task {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "creation_time")
    private LocalDateTime creationTime;
    @Column(name = "is_done")
    private Boolean isDone;
    @Column(nullable = false)
    private String title;
    private String description;

    public Task() {
    }

    public Task(String title, String description) {
        creationTime = LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
        isDone = false;

        this.title = title;
        this.description = description;
    }
}
